/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "GAME_CONTRACT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GameContract.findAll", query = "SELECT g FROM GameContract g"),
    @NamedQuery(name = "GameContract.findByGameContractId", query = "SELECT g FROM GameContract g WHERE g.gameContractId = :gameContractId"),
    @NamedQuery(name = "GameContract.getTeamsByGame", query = "SELECT gc FROM GameContract gc, Game g WHERE gc.gameId = g.gameId and g.gameId = :gameId")
})
public class GameContract extends AEntityContentProvider<GameContract> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
   // @SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=1)
    @Column(name = "GAME_CONTRACT_ID")
    private BigDecimal gameContractId;
    @JoinColumn(name = "TEAM_ID", referencedColumnName = "TEAM_ID")
    @ManyToOne
    private Team teamId;
    @JoinColumn(name = "GAME_ID", referencedColumnName = "GAME_ID")
    @ManyToOne
    private Game gameId;

    public GameContract() {
    }

    public GameContract(BigDecimal gameContractId) {
        super(GameContract.class);
        this.gameContractId = gameContractId;
    }

    public BigDecimal getGameContractId() {
        return gameContractId;
    }

    public void setGameContractId(BigDecimal gameContractId) {
        this.gameContractId = gameContractId;
    }

    public Team getTeamId() {
        return teamId;
    }

    public void setTeamId(Team teamId) {
        this.teamId = teamId;
    }

    public Game getGameId() {
        return gameId;
    }

    public void setGameId(Game gameId) {
        this.gameId = gameId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gameContractId != null ? gameContractId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GameContract)) {
            return false;
        }
        GameContract other = (GameContract) object;
        if ((this.gameContractId == null && other.gameContractId != null) || (this.gameContractId != null && !this.gameContractId.equals(other.gameContractId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.GameContract[ gameContractId=" + gameContractId + " ]";
    }
    
}
